/// \file profilemodel.h
///
///
///
#ifndef AKMODEL_H
#define AKMODEL_H

#include <QtCore/QtCore>
#include <QtGui/QMainWindow>
#include <QAbstractListModel>


#include <Phonon/MediaSource>
#include <Phonon/MediaObject>
#include <Phonon/AudioOutput>

#include "sounditem.h"

typedef QList<QByteArray> CategoryData;
typedef QMap<QString,CategoryData> UserData; ///< QMap<QString,QList<QByteArray>>



class AKModel : public QAbstractListModel
{
	Q_OBJECT

public:
	enum ModelRoles {
		PathRole = Qt::UserRole + 1,
		ThumbnailRole,
		TrainRole
	};

	AKModel(QObject *parent = 0);
	~AKModel();

	// needs to be implemented
	// return row count for given parent
	int rowCount(const QModelIndex &parent = QModelIndex()) const;
	// return data, based on current index and requested role
	QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;

	//////////////////////////////////////////////////////////////////////////


	void set(QByteArray hash = QByteArray());
	void set(QString user = QString(), QString category = QString(), int index = -1);

	SoundItem get(QByteArray hash = QByteArray());
	SoundItem get(QString user = QString(), QString category = QString(), int index = -1);

	void load(QStringList paths);
	void load(QString path);

	CategoryData isValid(QString user = QString(), QString category = QString(), int index = -1);



private:
	QMap<QByteArray,QByteArray> mData;
	QMap<QString,UserData> mOrganization;

	SoundItem *mCurrentItem;
	QString mCurrentUser;
	QString mCurrentCategory;
	//soundindex
	int mCurrentIndex;

	QStringList mAllPaths;

	void initialize();


	QString *currentPath;
	Phonon::MediaObject *mMediaObject;
	Phonon::AudioOutput *mAudioOutput;
	Phonon::MediaSource *mMediaSource;
	//QModelIndex parent(const QModelIndex &child) const;
	//int columnCount(const QModelIndex &parent) const;
	//bool hasChildren(const QModelIndex &parent) const;

	//Current Loaded Object


public slots:
};

#endif // AKMODEL_H